package com.young.mylib.utils;

import android.content.Context;
import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.AbsoluteSizeSpan;
import android.util.Log;

import com.young.mylib.R;

/**
 * Created by Young on 2019/6/4.
 */

public class SStringUtils {
    private final static String TAG = "SStringUtils";

    public static SpannableStringBuilder getSString(Context context, String str, int txtSize, int color) {
        if (txtSize == -1) {
            txtSize = (int) context.getResources().getDimension(R.dimen.x10);
        }
        str = " " + str + " ";
        SpannableStringBuilder ssb = new SpannableStringBuilder(str);
        RoundedBackgroundSpan span = new RoundedBackgroundSpan(context, color);
        ssb.setSpan(new AbsoluteSizeSpan(txtSize), 0, str.length(), Spannable.SPAN_INTERMEDIATE);
        ssb.setSpan(span, 0, str.length(), Spannable.SPAN_INTERMEDIATE);

        return ssb;
    }
}
